<template>
  <div class="app-container">
    <upload-excel-component :on-success="handleSuccess" :before-upload="beforeUpload" />
    <!--表单-->
    <div class="app-container" style="width: 100%">
      <el-table
        v-loading="listLoading"
        :data="list"
        element-loading-text="Loading"
        border
        fit
        highlight-current-row
      >
        <el-table-column align="center" label="教师"  prop="teacherId"/>
        <el-table-column align="center" label="课程"  prop="subId"/>
        <el-table-column align="center" label="分数"  prop="supervisionScore"/>
        <el-table-column align="center" label="评教时间"  prop="evaTime"/>
        <el-table-column align="center" label="学期"  prop="semester"/>
      </el-table>
      <el-pagination
        background layout="prev, pager, next"
        v-show="total > 0"
        :total="total"
        :current-page.sync="queryParams.pageNum"
        :page-size.sync="queryParams.pageSize"
        @current-change="handleSuccess"
      />
    </div>
  </div>
</template>

<script>
import UploadExcelComponent from '@/components/UploadExcel/index.vue'
import {getEvaluate2} from '@/api/table';

export default {
  name: 'UploadExcelEvaluateSupervision',
  components: { UploadExcelComponent },
  data() {
    return {
      total:0,
      list: [],//列表
      queryParams:{
        pageNum:1,
        pageSize:10,
      },
      listLoading: false
    }
  },
  methods: {
    beforeUpload(file) {
      const isLt1M = file.size / 1024 / 1024 < 20
      if (isLt1M) {
        console.log('调用了方法')
        return true
      }

      this.$message({
        message: '文件太大',
        type: 'warning'
      })
      return false
    },
    handleSuccess({ results, header }) {
      getEvaluate2(this.queryParams).then(res=>{
        this.list=res.data.rows
        this.total=res.data.total
        this.listLoading=false
      })
    }
  }
}
</script>
